package com.wsc.wisdomchinaqinghe.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wsc.wisdomchinaqinghe.R;
import com.wsc.wisdomchinaqinghe.javaBean.CommunityListSubBean;

import java.util.List;

/**
 * Created by Administrator on 2017/3/2 0002.
 */

public class HelpOldManSubAdapter extends BaseAdapter{
    private Context context;
    private List<CommunityListSubBean> list;

    public HelpOldManSubAdapter(Context context, List<CommunityListSubBean> list) {
        this.context = context;
        this.list=list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        Laonianrituo_holder holder=null;
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(context).inflate(R.layout.helpoldmansubitem,null);
            holder=new Laonianrituo_holder(view);
            view.setTag(holder);
        }else {
            holder= (Laonianrituo_holder) view.getTag();
        }
        CommunityListSubBean communityListSubBean=(CommunityListSubBean) getItem(position);
        Glide.with(context).load(communityListSubBean.getGuideImg()).into(holder.icon);
        holder.title.setText(communityListSubBean.getTitle());
        holder.location.setText(communityListSubBean.getPhone());
        holder.location_num.setText(communityListSubBean.getAddr());
        return view;
    }
    public class Laonianrituo_holder{
        private ImageView icon;
        private TextView title;
        private TextView location;
        private TextView location_num;
        public Laonianrituo_holder(View view) {
            icon= (ImageView) view.findViewById(R.id.item_icon);
            title= (TextView) view.findViewById(R.id.title);
            location= (TextView) view.findViewById(R.id.location);
            location_num= (TextView) view.findViewById(R.id.tv_location);
        }
    }
}
